package br.com.yetis.plugin.LoginOffline;

import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;

public class PlayerLoginOfflineListener implements Listener {

	private LoginOffline plugin;
	
	public PlayerLoginOfflineListener(LoginOffline instance) {
		this.plugin = instance;
	}
	
	@EventHandler(priority = EventPriority.LOWEST)
	public void PlayerChat(final AsyncPlayerChatEvent event)
	{
		Player player = event.getPlayer();
		if(plugin.isLoggedIn(player))
			return;
		
		event.setCancelled(true);
		player.sendMessage(ChatColor.RED + "[Yetis]Please login or register to start playing.");
	}
	
}
